﻿namespace HCRS.Implementation
{
    using HCRS.Errors;
    using Hubs1;
    using HUBS1;
    using System;
    using System.Collections;
    using System.Data;
    using System.IO;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Xml;

    /// <summary>
    /// 预订相关类推荐使用
    /// </summary>
    public class OrderClass
    {
        private static DataTable _Cxlreason = new DataTable();
        private static DataTable _Specialrequirement = new DataTable();

        static OrderClass()
        {
            _Cxlreason.Columns.Add("code");
            _Cxlreason.Columns.Add("zh");
            _Cxlreason.Columns.Add("en");
            _Cxlreason.Rows.Add(new object[] { "CRG01", "行程改变", "行程改变" });
            _Cxlreason.Rows.Add(new object[] { "CRG02", "无法满足特殊需求", "无法满足特殊需求" });
            _Cxlreason.Rows.Add(new object[] { "CRG03", "其他途径预订", "其他途径预订" });
            _Cxlreason.Rows.Add(new object[] { "CRG04", "预订其他酒店", "预订其他酒店" });
            _Cxlreason.Rows.Add(new object[] { "CRG05", "测试", "测试" });
            _Cxlreason.Rows.Add(new object[] { "CRG99", "其他", "其他" });
            _Specialrequirement.Columns.Add("code");
            _Specialrequirement.Columns.Add("zh");
            _Specialrequirement.Columns.Add("en");
            _Specialrequirement.Rows.Add(new object[] { "SPR01", "大床", "大床" });
            _Specialrequirement.Rows.Add(new object[] { "SPR02", "无烟房", "无烟房" });
            _Specialrequirement.Rows.Add(new object[] { "SPR03", "加床", "加床" });
            _Specialrequirement.Rows.Add(new object[] { "SPR04", "宽带", "宽带" });
            _Specialrequirement.Rows.Add(new object[] { "SPR05", "加早餐", "加早餐" });
        }

        private static string CheckGUA(string guaRateDetail, string guaPlan, string guaRateClass)
        {
            if (((guaRateDetail == "") || (guaRateDetail == null)) || (guaRateDetail == "无改变"))
            {
                if (guaPlan != "")
                {
                    return guaPlan;
                }
                return guaRateClass;
            }
            return guaRateDetail;
        }

        /// <summary>
        /// 订单取消 从crs上取消
        /// </summary>
        /// <param name="cxlnum">订单确认码</param>
        /// <param name="status">订单确认码</param>
        /// <param name="msg">错误信息</param>
        /// <returns></returns>
        public static bool cxlresv(ResvCancelInfo resv, out string cxlnum, out string status, out string msg)
        {
            cxlnum = "";
            msg = "";
            status = "";
            string xml = FogXml.cxlresv(resv, out msg);
            XmlDocument document = new XmlDocument();
            if (xml.Length >= 1)
            {
                try
                {
                    document.LoadXml(xml);
                    XmlNode node = document.SelectSingleNode("//srvmessage");
                    if (node == null)
                    {
                        throw new Exception("文档解析出错:[" + xml + "]");
                    }
                    if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNode node2 = document.SelectSingleNode("//resvdetail");
                        foreach (XmlElement element in node2)
                        {
                            if (element.Name == "status")
                            {
                                status = element.InnerText;
                            }
                            else if (element.Name == "cxlnum")
                            {
                                cxlnum = element.InnerText;
                            }
                        }
                        return true;
                    }
                    XmlNodeList list = document.SelectNodes("//error");
                    foreach (XmlNode node3 in list)
                    {
                        foreach (XmlElement element in node3.ChildNodes)
                        {
                            if (element.Name == "errormsg")
                            {
                                msg = msg + "|" + element.InnerText;
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    WebError.SendErrorEmail(exception, xml + msg, "fog cancelresv", "Fogxml");
                    msg = "ErrXMLdoc";
                }
            }
            return false;
        }

        /// <summary>
        /// 订单取消 从crs上取消
        /// </summary>
        /// <param name="pid">酒店id</param>
        /// <param name="confnum">订单确认码</param>
        /// <param name="cxlnum">订单确认码</param>
        /// <param name="status">订单确认码</param>
        /// <param name="msg">错误信息</param>
        /// <returns></returns>
        public static bool cxlresv(int pid, string confnum, out string cxlnum, out string status, out string msg)
        {
            return cxlresv(new ResvCancelInfo { pid = pid, confnum = confnum }, out cxlnum, out status, out msg);
        }

        /// <summary>
        /// 订单取消 从crs上取消
        /// </summary>
        /// <param name="pid">酒店id</param>
        /// <param name="verifycode">外部订单号</param>
        /// <param name="IATA">外部订单号</param>
        /// <param name="confnum">订单确认码</param>
        /// <param name="cxlnum">订单确认码</param>
        /// <param name="status">订单确认码</param> 
        /// <param name="msg">错误信息</param>
        /// <returns></returns>
        public static bool cxlresv(int pid, string verifycode, string IATA, out string confnum, out string cxlnum, out string status, out string msg)
        {
            cxlnum = "";
            msg = "";
            status = "";
            confnum = "";
            string xml = FogXml.cxlresv(pid, verifycode, IATA, out msg);
            XmlDocument document = new XmlDocument();
            if (xml.Length >= 1)
            {
                try
                {
                    document.LoadXml(xml);
                    XmlNode node = document.SelectSingleNode("//srvmessage");
                    if (node == null)
                    {
                        throw new Exception("文档解析出错:[" + xml + "]");
                    }
                    if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNode node2 = document.SelectSingleNode("//resvdetail");
                        foreach (XmlElement element in node2)
                        {
                            if (element.Name == "status")
                            {
                                status = element.InnerText;
                            }
                            else if (element.Name == "cxlnum")
                            {
                                cxlnum = element.InnerText;
                            }
                            else if (element.Name == "confnum")
                            {
                                confnum = element.InnerText;
                            }
                        }
                        return true;
                    }
                    XmlNodeList list = document.SelectNodes("//error");
                    foreach (XmlNode node3 in list)
                    {
                        foreach (XmlElement element in node3.ChildNodes)
                        {
                            if (element.Name == "errormsg")
                            {
                                msg = msg + "|" + element.InnerText;
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    msg = "ErrXMLdoc";
                    WebError.SendErrorEmail(exception);
                }
            }
            return false;
        }

        public static string GetBreakfastRemark(string num)
        {
            return GetBreakfastRemark(num, 0);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        public static string GetBreakfastRemark(string num, int lan)
        {
            if (lan == 0)
            {
                string[] strArray = new string[] { "无早", "单早", "双早", "三早", "四早", "五早", "六早", "七早", "八早", "九早" };
                try
                {
                    int index = Convert.ToInt32(num);
                    if (index < 10)
                    {
                        return strArray[index];
                    }
                    return (index + "早");
                }
                catch
                {
                    return "";
                }
            }
            if (num != "0")
            {
                return ("\x00d7" + num + " Breakfast included");
            }
            return "";
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="methodType"></param>
        /// <param name="errornum"></param>
        /// <param name="errorcode"></param>
        /// <param name="errorclass"></param>
        /// <param name="errormsg"></param>
        /// <returns></returns>
        public static string GetCrsError(string methodType, string errornum, string errorcode, string errorclass, string errormsg)
        {
            string str = string.Empty;
            switch (methodType)
            {
                case "modresv":
                    if (errormsg == "ErrEmpty")
                    {
                        str = "系统超时 友好提示：系统已在传输您的预订修改操作，请稍候在预订记录中查询，如有疑问请致电800-819-5677";
                    }
                    else if (errormsg == "ErrnoResponse")
                    {
                        str = "接口返回一个空值，这个订单可能已被其他人取消。";
                    }
                    else if (errormsg == "ErrConnect")
                    {
                        str = "暂时无法连接到中央预订系统";
                    }
                    else if (errormsg == "ErrXMLdoc")
                    {
                        str = "错误的文档，请您先查询订单状态";
                    }
                    else if (errormsg.IndexOf("Restriction") > 0)
                    {
                        str = "限制修改<li>如果该订单已被消单，不能修改。<li>过期订单不能修改。<li>当天入住订单并超过酒店保留时间不能修改。<li>酒店取消制度限制修改。";
                    }
                    else
                    {
                        str = errormsg;
                    }
                    return ("修改订单异常：" + str);

                case "cancelresv":
                    if (errormsg == "ErrEmpty")
                    {
                        str = "系统超时 友好提示：系统已在传输您的预订取消操作，请稍候在预订记录中查询，如有疑问请致电800-819-5677";
                    }
                    else if (errormsg == "ErrnoResponse")
                    {
                        str = "接口返回一个空值。";
                    }
                    else if (errormsg == "ErrConnect")
                    {
                        str = "暂时无法连接到中央预订系统";
                    }
                    else if (errormsg == "ErrXMLdoc")
                    {
                        str = "错误的文档，请您先查询订单状态";
                    }
                    else if (errormsg.IndexOf("Restriction") > 0)
                    {
                        str = "限制取消<li>如果该订单已被消单，不能重复取消。<li>过期订单不能取消。<li>当天入住订单并超过酒店保留时间不能取消。<li>酒店取消制度限制取消。";
                    }
                    else
                    {
                        str = errormsg;
                    }
                    return ("取消订单异常：" + str);

                case "newresv":
                    if (errormsg == "ErrEmpty")
                    {
                        str = "系统超时 友好提示：系统已在传输您的预订，请稍候在预订记录中查询，如有疑问请致电800-819-5677";
                    }
                    else if (errormsg == "ErrnoResponse")
                    {
                        str = "接口返回一个空值。";
                    }
                    else if (errormsg == "ErrConnect")
                    {
                        str = "暂时无法连接到中央预订系统";
                    }
                    else if (errormsg == "ErrXMLdoc")
                    {
                        str = "错误的文档，请您先查询订单状态";
                    }
                    else if (errormsg == "PropertyNA")
                    {
                        str = "预订失败<li>酒店暂时关闭了在线预订。";
                    }
                    else if (errormsg == "PlanNA")
                    {
                        str = "预订失败<li>该房型计划无可用房。";
                    }
                    else if (errormsg == "InvalidCCValue")
                    {
                        str = "预订失败<li>信用卡号码填写有误。";
                    }
                    else
                    {
                        str = errormsg;
                    }
                    return ("新订单异常：" + str);
            }
            return "访问接口时发生错误.";
        }

        /// <summary>
        /// 获取指定货币代码价格
        /// </summary>
        /// <param name="info">查询条件</param>
        /// <param name="msg">返回信息</param>
        /// <returns></returns>
        public static DataSet getexratemap(GetRateInfo info, out string msg)
        {
            DataSet set = new DataSet();
            DataTable table = new DataTable();
            DataTable table2 = new DataTable();
            table = set.Tables.Add("plantable");
            table2 = set.Tables.Add("ratetable");
            msg = "";
            table.Columns.Add("plancode", typeof(string));
            table.Columns.Add("planDesc", typeof(string));
            table.Columns.Add("planStatus", typeof(string));
            table.Columns.Add("planname", typeof(string));
            table.Columns.Add("roomDesc", typeof(string));
            table.Columns.Add("roomCode", typeof(string));
            table.Columns.Add("roomName", typeof(string));
            table.Columns.Add("rateDesc", typeof(string));
            table.Columns.Add("rateName", typeof(string));
            table.Columns.Add("rateCode", typeof(string));
            table.Columns.Add("Bed", typeof(bool));
            table.Columns.Add("BroadBand", typeof(bool));
            table.Columns.Add("Smoking", typeof(bool));
            table.Columns.Add("taxDesc", typeof(string));
            table.Columns.Add("resvgua", typeof(string));
            table.Columns.Add("resvcxl", typeof(string));
            table.Columns.Add("resvstatus", typeof(string));
            table.Columns.Add("resvguadesc", typeof(string));
            table.Columns.Add("resvcxldesc", typeof(string));
            table2.Columns.Add("plancode", typeof(string));
            table2.Columns.Add("Availdate", typeof(string));
            table2.Columns.Add("extraadult", typeof(string));
            table2.Columns.Add("Allotment", typeof(string));
            table2.Columns.Add("AvStat", typeof(string));
            table2.Columns.Add("MaxLos", typeof(string));
            table2.Columns.Add("MinLos", typeof(string));
            table2.Columns.Add("RateType", typeof(string));
            table2.Columns.Add("Gua", typeof(string));
            table2.Columns.Add("Cxl", typeof(string));
            table2.Columns.Add("PriceNoTax", typeof(decimal));
            table2.Columns.Add("CurrencyCode", typeof(string));
            table2.Columns.Add("BreakfastNum", typeof(int));
            table2.Columns.Add("BreakfastPay", typeof(decimal));
            table2.Columns.Add("BroadBand", typeof(bool));
            string str = "";
            string str14 = "";
            string str15 = "";
            string str16 = "";
            Hashtable hashtable = getplanset(info.pid, info.language);
            string xml = "";
            try
            {
                xml = FogXml.getratemap("getexratemap", info, out msg);
                if (msg != "")
                {
                    msg = "<li>&#x63A5;&#x53E3;&#x8BBF;&#x95EE;&#x5931;&#x8D25;&#xFF1A;" + msg;
                }
                XmlDocument document = new XmlDocument();
                document.LoadXml(xml);
                XmlNode node2 = document.SelectSingleNode("//srvmessage");
                if (node2 != null)
                {
                    if (node2.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNodeList list2 = document.SelectNodes("//ratedata");
                        foreach (XmlNode node3 in list2)
                        {
                            XmlNode node;
                            XmlNode node4 = node3.SelectSingleNode("plandetail");
                            XmlNode node5 = node3.SelectSingleNode("resv");
                            string str3 = "";
                            string str2 = "";
                            string str4 = "";
                            string str5 = "";
                            string str6 = "";
                            string str7 = "";
                            string str8 = "";
                            string str10 = "";
                            string str9 = "";
                            string str18 = "";
                            string str20 = "";
                            string innerText = "";
                            string str12 = "";
                            string str13 = "";
                            if (node5 != null)
                            {
                                node = node5.SelectSingleNode("ResvGua");
                                if (node != null)
                                {
                                    innerText = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvCxl");
                                if (node != null)
                                {
                                    str12 = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvStatus");
                                if (node != null)
                                {
                                    str13 = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvGuaDesc");
                                if (node != null)
                                {
                                    str14 = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvCxlDesc");
                                if (node != null)
                                {
                                    str15 = node.InnerText;
                                }
                            }
                            node = node4.SelectSingleNode("Desc");
                            if (node != null)
                            {
                                str3 = node.InnerText;
                            }
                            node = node4.SelectSingleNode("Status");
                            if (node != null)
                            {
                                str4 = node.InnerText;
                            }
                            node = node4.SelectSingleNode("PlanCode");
                            if (node != null)
                            {
                                str = node.InnerText;
                            }
                            node = node4.SelectSingleNode("Name");
                            if (node != null)
                            {
                                str2 = node.InnerText;
                            }
                            XmlNode node6 = node4.SelectSingleNode("RoomCode");
                            if (node6 != null)
                            {
                                str7 = node6.InnerText;
                            }
                            node6 = node4.SelectSingleNode("RateCode");
                            if (node6 != null)
                            {
                                str9 = node6.InnerText;
                            }
                            node = node4.SelectSingleNode("Room");
                            if (node != null)
                            {
                                node6 = node.SelectSingleNode("Desc");
                                if (node6 != null)
                                {
                                    str5 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("Name");
                                if (node6 != null)
                                {
                                    str6 = node6.InnerText;
                                }
                            }
                            node = node4.SelectSingleNode("Rate");
                            if (node != null)
                            {
                                node6 = node.SelectSingleNode("Desc");
                                if (node6 != null)
                                {
                                    str8 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("Name");
                                if (node6 != null)
                                {
                                    str10 = node6.InnerText;
                                }
                            }
                            DataRow row = table.NewRow();
                            row["plancode"] = str;
                            row["planDesc"] = str3;
                            row["planStatus"] = str4;
                            row["roomDesc"] = str5;
                            row["roomName"] = str6;
                            row["roomCode"] = str7;
                            row["rateDesc"] = str8;
                            row["rateName"] = str10;
                            row["rateCode"] = str9;
                            row["planname"] = str2;
                            row["resvgua"] = innerText;
                            row["resvcxl"] = str12;
                            row["resvstatus"] = str13;
                            row["resvguadesc"] = str14;
                            row["resvcxldesc"] = str15;
                            if (hashtable[str.ToLower()] != null)
                            {
                                bool[] flagArray = (bool[]) hashtable[str.ToLower()];
                                row["Bed"] = flagArray[0];
                                row["BroadBand"] = flagArray[1];
                                row["Smoking"] = flagArray[2];
                            }
                            table.Rows.Add(row);
                            XmlNodeList list = node3.SelectNodes("ratedetail");
                            foreach (XmlNode node7 in list)
                            {
                                string str17 = "";
                                int num = 0;
                                decimal num5 = 0M;
                                decimal num6 = 0M;
                                decimal num7 = 0M;
                                decimal num8 = 0M;
                                decimal num9 = 0M;
                                decimal num11 = 0M;
                                int num4 = 0;
                                int num3 = 0;
                                string str22 = "";
                                string str23 = "CNY";
                                int num12 = 0;
                                decimal num13 = 0M;
                                bool flag = false;
                                node = node7.SelectSingleNode("Date");
                                if (node != null)
                                {
                                    str17 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("Allotment");
                                if (node != null)
                                {
                                    num = Convert.ToInt32(node.InnerText);
                                }
                                node = node7.SelectSingleNode("RateSingle");
                                if (node != null)
                                {
                                    num5 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("RateDouble");
                                if (node != null)
                                {
                                    num6 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("RateTriple");
                                if (node != null)
                                {
                                    num7 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("RateQuad");
                                if (node != null)
                                {
                                    num8 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("RateExtraPerson");
                                if ((node != null) && (node.InnerText.Trim().Length > 0))
                                {
                                    num9 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("Total");
                                if (node != null)
                                {
                                    num11 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("GUA");
                                if (node != null)
                                {
                                    str18 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("CXL");
                                if (node != null)
                                {
                                    str20 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("AvailStatus");
                                if (node != null)
                                {
                                    str22 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("MaxLOS");
                                if (node != null)
                                {
                                    num4 = Convert.ToInt32(node.InnerText);
                                }
                                node = node7.SelectSingleNode("MinLOS");
                                if (node != null)
                                {
                                    num3 = Convert.ToInt32(node.InnerText);
                                }
                                node = node7.SelectSingleNode("BreakfastDesc");
                                if (node != null)
                                {
                                    string[] strArray = node.InnerText.Split(new char[] { '|' });
                                    if (strArray.Length > 1)
                                    {
                                        if (strArray[0].Length > 0)
                                        {
                                            num12 = Convert.ToInt32(strArray[0]);
                                        }
                                        if (strArray[1].Length > 0)
                                        {
                                            num13 = Convert.ToDecimal(strArray[1]);
                                        }
                                    }
                                }
                                node = node7.SelectSingleNode("NetDesc");
                                if (node != null)
                                {
                                    flag = node.InnerText.Trim().ToLower() == "free";
                                }
                                node = node7.SelectSingleNode("CurrenyCode");
                                if (node != null)
                                {
                                    str23 = node.InnerText;
                                }
                                string str26 = str18;
                                string str27 = str20;
                                DataRow row2 = table2.NewRow();
                                row2["plancode"] = str;
                                row2["Availdate"] = str17;
                                row2["extraadult"] = num9;
                                row2["PriceNoTax"] = num11;
                                row2["Allotment"] = num;
                                row2["AvStat"] = str22;
                                row2["MaxLos"] = num4;
                                row2["MinLos"] = num3;
                                row2["RateType"] = 0;
                                row2["Gua"] = str26;
                                row2["Cxl"] = str27;
                                row2["CurrencyCode"] = str23;
                                row2["BreakfastNum"] = num12;
                                row2["BreakfastPay"] = num13;
                                row2["BroadBand"] = flag;
                                table2.Rows.Add(row2);
                            }
                        }
                        if (table2.Rows.Count < info.nights)
                        {
                            if (info.language == 0)
                            {
                                msg = msg + "房量不足";
                                return set;
                            }
                            msg = msg + "noEnoughAvailRoom";
                        }
                        return set;
                    }
                    if (info.language == 0)
                    {
                        msg = msg + "错误";
                        return set;
                    }
                    msg = msg + "Error";
                    return set;
                }
                if (info.language == 0)
                {
                    msg = "未返回数据";
                    return set;
                }
                msg = "noResponse";
            }
            catch (Exception exception)
            {
                msg = "error" + exception.ToString() + str16;
                WebError.SendErrorEmail(exception, xml, "fog getragemap", "Fogxml");
            }
            return set;
        }

        public static DataSet getonlineratemap(GetRateInfo info, out string msg)
        {
            DataSet set = new DataSet();
            DataTable table = new DataTable();
            DataTable table2 = new DataTable();
            table = set.Tables.Add("plantable");
            table2 = set.Tables.Add("ratetable");
            msg = "";
            table.Columns.Add("plancode", typeof(string));
            table.Columns.Add("planDesc", typeof(string));
            table.Columns.Add("planStatus", typeof(string));
            table.Columns.Add("planname", typeof(string));
            table.Columns.Add("roomDesc", typeof(string));
            table.Columns.Add("roomCode", typeof(string));
            table.Columns.Add("roomName", typeof(string));
            table.Columns.Add("rateDesc", typeof(string));
            table.Columns.Add("rateName", typeof(string));
            table.Columns.Add("rateCode", typeof(string));
            table.Columns.Add("Bed", typeof(bool));
            table.Columns.Add("BroadBand", typeof(bool));
            table.Columns.Add("Smoking", typeof(bool));
            table.Columns.Add("taxDesc", typeof(string));
            table.Columns.Add("resvgua", typeof(string));
            table.Columns.Add("resvcxl", typeof(string));
            table.Columns.Add("resvstatus", typeof(string));
            table.Columns.Add("resvguadesc", typeof(string));
            table.Columns.Add("resvcxldesc", typeof(string));
            table2.Columns.Add("plancode", typeof(string));
            table2.Columns.Add("Availdate", typeof(string));
            table2.Columns.Add("extraadult", typeof(string));
            table2.Columns.Add("Allotment", typeof(string));
            table2.Columns.Add("AvStat", typeof(string));
            table2.Columns.Add("MaxLos", typeof(string));
            table2.Columns.Add("MinLos", typeof(string));
            table2.Columns.Add("RateType", typeof(string));
            table2.Columns.Add("Gua", typeof(string));
            table2.Columns.Add("Cxl", typeof(string));
            table2.Columns.Add("PriceNoTax", typeof(decimal));
            table2.Columns.Add("CurrencyCode", typeof(string));
            table2.Columns.Add("BreakfastNum", typeof(int));
            table2.Columns.Add("BreakfastPay", typeof(decimal));
            table2.Columns.Add("BroadBand", typeof(bool));
            string str = "";
            string str14 = "";
            string str15 = "";
            string str16 = "";
            Hashtable hashtable = getplanset(info.pid, info.language);
            string xml = "";
            try
            {
                xml = FogXml.getonlineratemap(info, out msg);
                if (msg != "")
                {
                    msg = "<li>&#x63A5;&#x53E3;&#x8BBF;&#x95EE;&#x5931;&#x8D25;&#xFF1A;" + msg;
                }
                XmlDocument document = new XmlDocument();
                document.LoadXml(xml);
                XmlNode node2 = document.SelectSingleNode("//srvmessage");
                if (node2 != null)
                {
                    if (node2.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNodeList list2 = document.SelectNodes("//ratedata");
                        foreach (XmlNode node3 in list2)
                        {
                            XmlNode node;
                            XmlNode node6;
                            XmlNode node4 = node3.SelectSingleNode("plandetail");
                            XmlNode node5 = node3.SelectSingleNode("resv");
                            string str3 = "";
                            string str2 = "";
                            string str4 = "";
                            string str5 = "";
                            string str6 = "";
                            string str7 = "";
                            string str8 = "";
                            string str10 = "";
                            string ratecode = "";
                            string str18 = "";
                            string str20 = "";
                            string gua = "";
                            string cxl = "";
                            string innerText = "";
                            if (node5 != null)
                            {
                                node = node5.SelectSingleNode("ResvGua");
                                if (node != null)
                                {
                                    gua = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvCxl");
                                if (node != null)
                                {
                                    cxl = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvStatus");
                                if (node != null)
                                {
                                    innerText = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvGuaDesc");
                                if (node != null)
                                {
                                    str14 = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvCxlDesc");
                                if (node != null)
                                {
                                    str15 = node.InnerText;
                                }
                            }
                            node = node4.SelectSingleNode("Description");
                            if (node != null)
                            {
                                str3 = node.InnerText;
                            }
                            node = node4.SelectSingleNode("Status");
                            if (node != null)
                            {
                                str4 = node.InnerText;
                            }
                            node = node4.SelectSingleNode("plan");
                            if (node != null)
                            {
                                str = node.InnerText;
                            }
                            node = node4.SelectSingleNode("name");
                            if (node != null)
                            {
                                str2 = node.InnerText;
                            }
                            node = node4.SelectSingleNode("roomtype");
                            if (node != null)
                            {
                                node6 = node.SelectSingleNode("Desc1");
                                if (node6 != null)
                                {
                                    str5 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("name");
                                if (node6 != null)
                                {
                                    str6 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("room");
                                if (node6 != null)
                                {
                                    str7 = node6.InnerText;
                                }
                            }
                            node = node4.SelectSingleNode("rateclass");
                            if (node != null)
                            {
                                node6 = node.SelectSingleNode("Desc1");
                                if (node6 != null)
                                {
                                    str8 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("name");
                                if (node6 != null)
                                {
                                    str10 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("GuaranteeRule");
                                if (node6 != null)
                                {
                                    str18 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("CancelRule");
                                if (node6 != null)
                                {
                                    str20 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("rate");
                                if (node6 != null)
                                {
                                    ratecode = node6.InnerText;
                                }
                            }
                            DataRow row = table.NewRow();
                            row["plancode"] = str;
                            row["planDesc"] = str3;
                            row["planStatus"] = str4;
                            row["roomDesc"] = str5;
                            row["roomName"] = str6;
                            row["roomCode"] = str7;
                            row["rateDesc"] = str8;
                            row["rateName"] = str10;
                            row["rateCode"] = ratecode;
                            row["planname"] = str2;
                            row["taxDesc"] = getOrderRule(info.pid, gua, cxl, ratecode, info.language).Tax;
                            row["resvgua"] = gua;
                            row["resvcxl"] = cxl;
                            row["resvstatus"] = innerText;
                            row["resvguadesc"] = str14;
                            row["resvcxldesc"] = str15;
                            if (hashtable[str.ToLower()] != null)
                            {
                                bool[] flagArray = (bool[]) hashtable[str.ToLower()];
                                row["Bed"] = flagArray[0];
                                row["BroadBand"] = flagArray[1];
                                row["Smoking"] = flagArray[2];
                            }
                            table.Rows.Add(row);
                            XmlNodeList list = node3.SelectNodes("ratedetail");
                            foreach (XmlNode node7 in list)
                            {
                                string str17 = "";
                                int num = 0;
                                int num2 = 0;
                                decimal num5 = 0M;
                                decimal num6 = 0M;
                                decimal num7 = 0M;
                                decimal num8 = 0M;
                                decimal num9 = 0M;
                                decimal num10 = 0M;
                                decimal num11 = 0M;
                                int num4 = 0;
                                int num3 = 0;
                                string str22 = "";
                                string str23 = "CNY";
                                int num12 = 0;
                                decimal num13 = 0M;
                                bool flag = false;
                                node = node7.SelectSingleNode("date");
                                if (node != null)
                                {
                                    str17 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("Allotment");
                                if (node != null)
                                {
                                    num = Convert.ToInt32(node.InnerText);
                                }
                                node = node7.SelectSingleNode("Single");
                                if (node != null)
                                {
                                    num5 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("Double");
                                if (node != null)
                                {
                                    num6 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("Triple");
                                if (node != null)
                                {
                                    num7 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("Quad");
                                if (node != null)
                                {
                                    num8 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("ExtraPerson");
                                if ((node != null) && (node.InnerText.Trim().Length > 0))
                                {
                                    num9 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("ExtraChild");
                                if ((node != null) && (node.InnerText.Trim().Length > 0))
                                {
                                    num10 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("Total");
                                if (node != null)
                                {
                                    num11 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("GUA");
                                if (node != null)
                                {
                                    str18 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("CXL");
                                if (node != null)
                                {
                                    str20 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("AvStat");
                                if (node != null)
                                {
                                    str22 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("MaxLOS");
                                if (node != null)
                                {
                                    num4 = Convert.ToInt32(node.InnerText);
                                }
                                node = node7.SelectSingleNode("MinLOS");
                                if (node != null)
                                {
                                    num3 = Convert.ToInt32(node.InnerText);
                                }
                                node = node7.SelectSingleNode("AllotCeil");
                                if (node != null)
                                {
                                    num2 = Convert.ToInt32(node.InnerText);
                                }
                                node = node7.SelectSingleNode("BreakfastDesc");
                                if (node != null)
                                {
                                    string[] strArray = node.InnerText.Split(new char[] { '|' });
                                    if (strArray.Length > 1)
                                    {
                                        if (strArray[0].Length > 0)
                                        {
                                            num12 = Convert.ToInt32(strArray[0]);
                                        }
                                        if (strArray[1].Length > 0)
                                        {
                                            num13 = Convert.ToDecimal(strArray[1]);
                                        }
                                    }
                                }
                                node = node7.SelectSingleNode("NetDesc");
                                if (node != null)
                                {
                                    flag = node.InnerText.Trim().ToLower() == "free";
                                }
                                node = node7.SelectSingleNode("CurrenyCode");
                                if (node != null)
                                {
                                    str23 = node.InnerText;
                                }
                                string str26 = str18;
                                string str27 = str20;
                                DataRow row2 = table2.NewRow();
                                row2["plancode"] = str;
                                row2["Availdate"] = str17;
                                row2["extraadult"] = num9;
                                row2["PriceNoTax"] = num11;
                                row2["Allotment"] = num;
                                row2["AvStat"] = str22;
                                row2["MaxLos"] = num4;
                                row2["MinLos"] = num3;
                                row2["RateType"] = 0;
                                row2["Gua"] = str26;
                                row2["Cxl"] = str27;
                                row2["CurrencyCode"] = str23;
                                row2["BreakfastNum"] = num12;
                                row2["BreakfastPay"] = num13;
                                row2["BroadBand"] = flag;
                                table2.Rows.Add(row2);
                            }
                        }
                        if (table2.Rows.Count < info.nights)
                        {
                            if (info.language == 0)
                            {
                                msg = msg + "房量不足";
                                return set;
                            }
                            msg = msg + "noEnoughAvailRoom";
                        }
                        return set;
                    }
                    if (info.language == 0)
                    {
                        msg = msg + "错误";
                        return set;
                    }
                    msg = msg + "Error";
                    return set;
                }
                if (info.language == 0)
                {
                    msg = "未返回数据";
                    return set;
                }
                msg = "noResponse";
            }
            catch (Exception exception)
            {
                msg = "error" + exception.ToString() + str16;
                WebError.SendErrorEmail(exception, xml, "fog getragemap", "Fogxml");
            }
            return set;
        }

        /// <summary>
        /// 预订取消保证金税收政策
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="gua"></param>
        /// <param name="cxl"></param>
        /// <param name="ratecode"></param>
        /// <param name="lan"></param>
        /// <returns></returns>
        public static OrderRule getOrderRule(int pid, string gua, string cxl, string ratecode, int lan)
        {
            StringBuilder builder = new StringBuilder();
            OrderRule rule = new OrderRule();
            DataSet dataSet = CommonDataAccess.GetDataSet(string.Concat(new object[] { 
                "select * from H_guarule where property_id=", pid, "  and Grule='", gua, "' and languagetype=", lan, "; select * from H_cxlrule where Property_id=", pid, "  and [Rule]='", cxl, "' and languagetype=", lan, "; select a.*,b.[include] from H_tax a inner join H_taxrate b on a.property_id=b.property_id and b.tax=a.code and b.rate='", ratecode, "' and  a.languagetype=", lan, 
                " and a.property_id=", pid, ";"
             }));
            if (dataSet != null)
            {
                DataTable table;
                string str2;
                string str3;
                string str4;
                string str5;
                string str6;
                if (lan == 1)
                {
                    table = dataSet.Tables[0];
                    if ((((table != null) && (table.Rows.Count > 0)) && (table.Rows[0]["GDescription"] != null)) && (table.Rows[0]["GDescription"].ToString() != ""))
                    {
                        rule.Gua = table.Rows[0]["GDescription"].ToString();
                    }
                    table = dataSet.Tables[1];
                    if ((((table != null) && (table.Rows.Count > 0)) && (table.Rows[0]["Description"] != null)) && (table.Rows[0]["Description"].ToString() != ""))
                    {
                        rule.Cxl = table.Rows[0]["Description"].ToString();
                    }
                    table = dataSet.Tables[2];
                    foreach (DataRow row in table.Rows)
                    {
                        str2 = row["include"].ToString();
                        str3 = row["typecode"].ToString();
                        str4 = row["application"].ToString();
                        str6 = str4;
                        if (str6 != null)
                        {
                            if (!(str6 == "RS"))
                            {
                                if (str6 == "RN")
                                {
                                    goto Label_02CE;
                                }
                                if (str6 == "PS")
                                {
                                    goto Label_02D7;
                                }
                                if (str6 == "PN")
                                {
                                    goto Label_02E0;
                                }
                            }
                            else
                            {
                                str4 = "per room/stay";
                            }
                        }
                        goto Label_02E9;
                    Label_02CE:
                        str4 = "per room/night";
                        goto Label_02E9;
                    Label_02D7:
                        str4 = "per person/stay";
                        goto Label_02E9;
                    Label_02E0:
                        str4 = "per person/night";
                    Label_02E9:
                        row["application"] = str4;
                        str5 = row["method"].ToString();
                        if ((str3 == "SC") && ((row["code"].ToString() == "SVC") || (row["code"].ToString() == "SERVICECHARGE")))
                        {
                            if (str2 == "0")
                            {
                                if (str5 == "P")
                                {
                                    str5 = "Subject to " + row["amount"].ToString() + "% service charge";
                                }
                                else
                                {
                                    str5 = "Subject to CNY" + row["amount"].ToString() + " service charge";
                                }
                            }
                            else if (str5 == "P")
                            {
                                str5 = "Included " + row["amount"].ToString() + "% service charge";
                            }
                            else
                            {
                                str5 = "Included CNY" + row["amount"].ToString() + " service charge";
                            }
                        }
                        else
                        {
                            if (str2 == "0")
                            {
                                str2 = "Subject to ";
                            }
                            else
                            {
                                str2 = "Included ";
                            }
                            str6 = str5;
                            if (str6 != null)
                            {
                                if (!(str6 == "P"))
                                {
                                    if (str6 == "M")
                                    {
                                        goto Label_04F4;
                                    }
                                }
                                else
                                {
                                    str5 = str2 + row["Description"].ToString() + " " + row["amount"].ToString() + "% of total amount " + str4;
                                }
                            }
                        }
                        goto Label_0550;
                    Label_04F4:;
                        str5 = str2 + row["Description"].ToString() + " CNY" + row["amount"].ToString() + " " + str4;
                    Label_0550:
                        builder.Append(str5 + ".</br>");
                    }
                    rule.Tax = builder.ToString();
                    return rule;
                }
                table = dataSet.Tables[0];
                if ((((table != null) && (table.Rows.Count > 0)) && (table.Rows[0]["GDescription"] != null)) && (table.Rows[0]["GDescription"].ToString() != ""))
                {
                    rule.Gua = table.Rows[0]["GDescription"].ToString();
                }
                table = dataSet.Tables[1];
                if ((((table != null) && (table.Rows.Count > 0)) && (table.Rows[0]["Description"] != null)) && (table.Rows[0]["Description"].ToString() != ""))
                {
                    rule.Cxl = table.Rows[0]["Description"].ToString();
                }
                table = dataSet.Tables[2];
                foreach (DataRow row in table.Rows)
                {
                    str2 = row["include"].ToString();
                    str3 = row["typecode"].ToString();
                    str4 = row["application"].ToString();
                    str6 = str4;
                    if (str6 != null)
                    {
                        if (!(str6 == "RS"))
                        {
                            if (str6 == "RN")
                            {
                                goto Label_077F;
                            }
                            if (str6 == "PS")
                            {
                                goto Label_0788;
                            }
                            if (str6 == "PN")
                            {
                                goto Label_0791;
                            }
                        }
                        else
                        {
                            str4 = "每间每次";
                        }
                    }
                    goto Label_079A;
                Label_077F:
                    str4 = "每间每晚";
                    goto Label_079A;
                Label_0788:
                    str4 = "每人每次";
                    goto Label_079A;
                Label_0791:
                    str4 = "每人每晚";
                Label_079A:
                    row["application"] = str4;
                    str5 = row["method"].ToString();
                    if ((str3 == "SC") && ((row["code"].ToString() == "SVC") || (row["code"].ToString() == "SERVICECHARGE")))
                    {
                        if (str2 == "0")
                        {
                            if (str5 == "P")
                            {
                                str5 = "需另加收" + row["amount"].ToString() + "%作为服务费";
                            }
                            else
                            {
                                str5 = "收取金额CNY" + row["amount"].ToString() + "作为服务费";
                            }
                        }
                        else if (str5 == "P")
                        {
                            str5 = "已包含" + row["amount"].ToString() + "%作为服务费";
                        }
                        else
                        {
                            str5 = "已包含CNY" + row["amount"].ToString() + "作为服务费";
                        }
                    }
                    else
                    {
                        if (str2 == "0")
                        {
                            str2 = "需另加收 ";
                        }
                        else
                        {
                            str2 = "已包含";
                        }
                        str6 = str5;
                        if (str6 != null)
                        {
                            if (!(str6 == "P"))
                            {
                                if (str6 == "M")
                                {
                                    goto Label_09A5;
                                }
                            }
                            else
                            {
                                str5 = str2 + str4 + "" + row["amount"].ToString() + "%" + row["Description"].ToString();
                            }
                        }
                    }
                    goto Label_09F8;
                Label_09A5:;
                    str5 = str2 + str4 + " CNY" + row["amount"].ToString() + row["Description"].ToString();
                Label_09F8:
                    builder.Append(str5 + "。</br>");
                }
                rule.Tax = builder.ToString();
            }
            return rule;
        }

        /// <summary>
        /// 查询酒店计划配置
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="language"></param>
        /// <returns></returns>
        private static Hashtable getplanset(int pid, int language)
        {
            DataTable table = CommonDataAccess.GetTable(string.Concat(new object[] { "select plancode,addbed,net,nosmoke from H_Plan where type='plan' and languagetype=", language, " and property_id=", pid }), "");
            Hashtable hashtable = new Hashtable();
            try
            {
                if ((table == null) || (table.Rows.Count <= 0))
                {
                    return hashtable;
                }
                bool flag = false;
                bool flag2 = false;
                bool flag3 = false;
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    flag = (table.Rows[i]["addbed"].ToString().ToLower() == "1") || (table.Rows[i]["addbed"].ToString().ToLower() == "true");
                    flag2 = (table.Rows[i]["net"].ToString().ToLower() == "1") || (table.Rows[i]["net"].ToString().ToLower() == "true");
                    flag3 = (table.Rows[i]["nosmoke"].ToString().ToLower() == "1") || (table.Rows[i]["nosmoke"].ToString().ToLower() == "true");
                    hashtable.Add(table.Rows[i]["plancode"].ToString().ToLower(), new bool[] { flag, flag2, flag3 });
                }
            }
            catch (Exception)
            {
            }
            return hashtable;
        }

        /// <summary>
        /// 获取酒店可用房型价格
        /// </summary>
        /// <param name="info">查询条件</param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static DataSet getratemap(GetRateInfo info, out string msg)
        {
            return getratemap("getexratemap", info, out msg);
        }

        /// <summary>
        /// 获取Fog价格
        /// </summary>
        /// <param name="actionname">操作类型</param>
        /// <param name="info">查询条件</param>
        /// <param name="msg">返回信息</param>
        /// <returns></returns>
        private static DataSet getratemap(string actionname, GetRateInfo info, out string msg)
        {
            DataSet set = new DataSet();
            DataTable table = new DataTable();
            DataTable table2 = new DataTable();
            table = set.Tables.Add("plantable");
            table2 = set.Tables.Add("ratetable");
            msg = "";
            table.Columns.Add("plancode", typeof(string));
            table.Columns.Add("planDesc", typeof(string));
            table.Columns.Add("planStatus", typeof(string));
            table.Columns.Add("planname", typeof(string));
            table.Columns.Add("roomDesc", typeof(string));
            table.Columns.Add("roomCode", typeof(string));
            table.Columns.Add("roomName", typeof(string));
            table.Columns.Add("rateDesc", typeof(string));
            table.Columns.Add("rateName", typeof(string));
            table.Columns.Add("rateCode", typeof(string));
            table.Columns.Add("Bed", typeof(bool));
            table.Columns.Add("BroadBand", typeof(bool));
            table.Columns.Add("Smoking", typeof(bool));
            table.Columns.Add("taxDesc", typeof(string));
            table.Columns.Add("resvgua", typeof(string));
            table.Columns.Add("resvcxl", typeof(string));
            table.Columns.Add("resvstatus", typeof(string));
            table.Columns.Add("resvguadesc", typeof(string));
            table.Columns.Add("resvcxldesc", typeof(string));
            table2.Columns.Add("plancode", typeof(string));
            table2.Columns.Add("Availdate", typeof(string));
            table2.Columns.Add("extraadult", typeof(string));
            table2.Columns.Add("Allotment", typeof(string));
            table2.Columns.Add("AvStat", typeof(string));
            table2.Columns.Add("MaxLos", typeof(string));
            table2.Columns.Add("MinLos", typeof(string));
            table2.Columns.Add("RateType", typeof(string));
            table2.Columns.Add("Gua", typeof(string));
            table2.Columns.Add("Cxl", typeof(string));
            table2.Columns.Add("PriceNoTax", typeof(decimal));
            if (actionname == "getexzratemap")
            {
                table2.Columns.Add("CurrencyCode", typeof(string));
                table2.Columns.Add("BreakfastNum", typeof(int));
                table2.Columns.Add("BreakfastPay", typeof(decimal));
                table2.Columns.Add("BroadBand", typeof(bool));
            }
            string str = "";
            string str14 = "";
            string str15 = "";
            string str16 = "";
            Hashtable hashtable = getplanset(info.pid, info.language);
            string xml = "";
            try
            {
                xml = FogXml.getratemap(actionname, info, out msg);
                if (msg != "")
                {
                    msg = "<li>&#x63A5;&#x53E3;&#x8BBF;&#x95EE;&#x5931;&#x8D25;&#xFF1A;" + msg;
                }
                XmlDocument document = new XmlDocument();
                document.LoadXml(xml);
                XmlNode node2 = document.SelectSingleNode("//srvmessage");
                if (node2 != null)
                {
                    if (node2.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNodeList list2 = document.SelectNodes("//ratedata");
                        foreach (XmlNode node3 in list2)
                        {
                            XmlNode node;
                            XmlNode node6;
                            XmlNode node4 = node3.SelectSingleNode("plandetail");
                            XmlNode node5 = node3.SelectSingleNode("resv");
                            string str3 = "";
                            string str2 = "";
                            string str4 = "";
                            string str5 = "";
                            string str6 = "";
                            string str7 = "";
                            string str8 = "";
                            string str10 = "";
                            string str9 = "";
                            string str18 = "";
                            string str20 = "";
                            string innerText = "";
                            string str12 = "";
                            string str13 = "";
                            if (node5 != null)
                            {
                                node = node5.SelectSingleNode("ResvGua");
                                if (node != null)
                                {
                                    innerText = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvCxl");
                                if (node != null)
                                {
                                    str12 = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvStatus");
                                if (node != null)
                                {
                                    str13 = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvGuaDesc");
                                if (node != null)
                                {
                                    str14 = node.InnerText;
                                }
                                node = node5.SelectSingleNode("ResvCxlDesc");
                                if (node != null)
                                {
                                    str15 = node.InnerText;
                                }
                            }
                            node = node4.SelectSingleNode("Description");
                            if (node != null)
                            {
                                str3 = node.InnerText;
                            }
                            node = node4.SelectSingleNode("Status");
                            if (node != null)
                            {
                                str4 = node.InnerText;
                            }
                            node = node4.SelectSingleNode("plan");
                            if (node != null)
                            {
                                str = node.InnerText;
                            }
                            node = node4.SelectSingleNode("name");
                            if (node != null)
                            {
                                str2 = node.InnerText;
                            }
                            node = node4.SelectSingleNode("roomtype");
                            if (node != null)
                            {
                                node6 = node.SelectSingleNode("Desc1");
                                if (node6 != null)
                                {
                                    str5 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("name");
                                if (node6 != null)
                                {
                                    str6 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("room");
                                if (node6 != null)
                                {
                                    str7 = node6.InnerText;
                                }
                            }
                            node = node4.SelectSingleNode("rateclass");
                            if (node != null)
                            {
                                node6 = node.SelectSingleNode("Desc1");
                                if (node6 != null)
                                {
                                    str8 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("name");
                                if (node6 != null)
                                {
                                    str10 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("GuaranteeRule");
                                if (node6 != null)
                                {
                                    str18 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("CancelRule");
                                if (node6 != null)
                                {
                                    str20 = node6.InnerText;
                                }
                                node6 = node.SelectSingleNode("rate");
                                if (node6 != null)
                                {
                                    str9 = node6.InnerText;
                                }
                            }
                            DataRow row = table.NewRow();
                            row["plancode"] = str;
                            row["planDesc"] = str3;
                            row["planStatus"] = str4;
                            row["roomDesc"] = str5;
                            row["roomName"] = str6;
                            row["roomCode"] = str7;
                            row["rateDesc"] = str8;
                            row["rateName"] = str10;
                            row["rateCode"] = str9;
                            row["planname"] = str2;
                            row["resvgua"] = innerText;
                            row["resvcxl"] = str12;
                            row["resvstatus"] = str13;
                            row["resvguadesc"] = str14;
                            row["resvcxldesc"] = str15;
                            if (hashtable[str.ToLower()] != null)
                            {
                                bool[] flagArray = (bool[]) hashtable[str.ToLower()];
                                row["Bed"] = flagArray[0];
                                row["BroadBand"] = flagArray[1];
                                row["Smoking"] = flagArray[2];
                            }
                            table.Rows.Add(row);
                            XmlNodeList list = node3.SelectNodes("ratedetail");
                            foreach (XmlNode node7 in list)
                            {
                                string str17 = "";
                                int num = 0;
                                int num2 = 0;
                                decimal num5 = 0M;
                                decimal num6 = 0M;
                                decimal num7 = 0M;
                                decimal num8 = 0M;
                                decimal num9 = 0M;
                                decimal num10 = 0M;
                                decimal num11 = 0M;
                                int num4 = 0;
                                int num3 = 0;
                                string str22 = "";
                                string str23 = "CNY";
                                int num12 = 0;
                                decimal num13 = 0M;
                                bool flag = false;
                                node = node7.SelectSingleNode("date");
                                if (node != null)
                                {
                                    str17 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("Allotment");
                                if (node != null)
                                {
                                    num = Convert.ToInt32(node.InnerText);
                                }
                                node = node7.SelectSingleNode("Single");
                                if (node != null)
                                {
                                    num5 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("Double");
                                if (node != null)
                                {
                                    num6 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("Triple");
                                if (node != null)
                                {
                                    num7 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("Quad");
                                if (node != null)
                                {
                                    num8 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("ExtraPerson");
                                if ((node != null) && (node.InnerText.Trim().Length > 0))
                                {
                                    num9 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("ExtraChild");
                                if ((node != null) && (node.InnerText.Trim().Length > 0))
                                {
                                    num10 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("Total");
                                if (node != null)
                                {
                                    num11 = Convert.ToDecimal(node.InnerText);
                                }
                                node = node7.SelectSingleNode("GUA");
                                if (node != null)
                                {
                                    str18 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("CXL");
                                if (node != null)
                                {
                                    str20 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("AvStat");
                                if (node != null)
                                {
                                    str22 = node.InnerText;
                                }
                                node = node7.SelectSingleNode("MaxLOS");
                                if (node != null)
                                {
                                    num4 = Convert.ToInt32(node.InnerText);
                                }
                                node = node7.SelectSingleNode("MinLOS");
                                if (node != null)
                                {
                                    num3 = Convert.ToInt32(node.InnerText);
                                }
                                node = node7.SelectSingleNode("AllotCeil");
                                if (node != null)
                                {
                                    num2 = Convert.ToInt32(node.InnerText);
                                }
                                node = node7.SelectSingleNode("BreakfastDesc");
                                if (node != null)
                                {
                                    string[] strArray = node.InnerText.Split(new char[] { '|' });
                                    if (strArray.Length > 1)
                                    {
                                        if (strArray[0].Length > 0)
                                        {
                                            num12 = Convert.ToInt32(strArray[0]);
                                        }
                                        if (strArray[1].Length > 0)
                                        {
                                            num13 = Convert.ToDecimal(strArray[1]);
                                        }
                                    }
                                }
                                node = node7.SelectSingleNode("NetDesc");
                                if (node != null)
                                {
                                    flag = node.InnerText.Trim().ToLower() == "free";
                                }
                                node = node7.SelectSingleNode("CurrenyCode");
                                if (node != null)
                                {
                                    str23 = node.InnerText;
                                }
                                string str26 = str18;
                                string str27 = str20;
                                DataRow row2 = table2.NewRow();
                                row2["plancode"] = str;
                                row2["Availdate"] = str17;
                                row2["extraadult"] = num9;
                                row2["PriceNoTax"] = num11;
                                row2["Allotment"] = num;
                                row2["AvStat"] = str22;
                                row2["MaxLos"] = num4;
                                row2["MinLos"] = num3;
                                row2["RateType"] = 0;
                                row2["Gua"] = str26;
                                row2["Cxl"] = str27;
                                if (actionname == "getexzratemap")
                                {
                                    row2["CurrencyCode"] = str23;
                                    row2["BreakfastNum"] = num12;
                                    row2["BreakfastPay"] = num13;
                                    row2["BroadBand"] = flag;
                                }
                                table2.Rows.Add(row2);
                            }
                        }
                        if (table2.Rows.Count < info.nights)
                        {
                            if (info.language == 0)
                            {
                                msg = msg + "房量不足";
                                return set;
                            }
                            msg = msg + "noEnoughAvailRoom";
                        }
                        return set;
                    }
                    if (info.language == 0)
                    {
                        msg = msg + "错误";
                        return set;
                    }
                    msg = msg + "Error";
                    return set;
                }
                if (info.language == 0)
                {
                    msg = "未返回数据";
                    return set;
                }
                msg = "noResponse";
            }
            catch (Exception exception)
            {
                msg = "error" + exception.ToString() + str16;
                WebError.SendErrorEmail(exception, xml, "fog getragemap", "Fogxml");
            }
            return set;
        }

        /// <summary>
        /// 获取订单
        /// </summary>
        /// <returns></returns>
        public static bool getresv()
        {
            return false;
        }

        /// <summary>
        /// 订单修改 
        /// </summary>
        /// <param name="resv">订单信息</param>
        /// <param name="status">订单状态</param>
        /// <param name="msg">错误信息</param>
        /// <returns></returns>
        public static bool modresv(ResvModifyInfo resv, out string status, out string msg)
        {
            msg = "";
            status = "";
            string innerText = "";
            string xml = FogXml.modresv(resv, out msg);
            XmlDocument document = new XmlDocument();
            if (xml.Length >= 1)
            {
                try
                {
                    document.LoadXml(xml);
                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
                    nsmgr.AddNamespace("err", "http://www.hubs1.net/gxml/error");
                    XmlNode node = document.SelectSingleNode("//err:srvmessage", nsmgr);
                    if (node == null)
                    {
                        node = document.SelectSingleNode("srvmessage");
                    }
                    if (node == null)
                    {
                        throw new Exception("文档解析出错:[" + xml + "]");
                    }
                    if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNode node2 = document.SelectSingleNode("//resvdetail");
                        if (node2.ChildNodes.Count > 0)
                        {
                            foreach (XmlElement element in node2)
                            {
                                if (element.Name == "confnum")
                                {
                                    innerText = element.InnerText;
                                }
                                else if (element.Name == "status")
                                {
                                    status = element.InnerText;
                                }
                            }
                            return true;
                        }
                        msg = "ErrConfnum";
                    }
                    else
                    {
                        XmlNodeList list = document.SelectNodes("//err:error", nsmgr);
                        foreach (XmlNode node3 in list)
                        {
                            foreach (XmlElement element in node3.ChildNodes)
                            {
                                if (element.Name == "errormsg")
                                {
                                    msg = msg + "|" + element.InnerText;
                                }
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    msg = "error" + exception.ToString() + msg;
                    WebError.SendErrorEmail(exception, xml + msg, "fog modresv", "Fogxml");
                }
            }
            return false;
        }

        /// <summary>
        /// 订单修改 
        /// </summary>
        /// <param name="pid">酒店id</param>
        /// <param name="confnum">确认码</param>
        /// <param name="firstname">姓</param>
        /// <param name="lastname">名</param>
        /// <param name="guestaddressline1">客人地址</param>
        /// <param name="guestphone">客人电话</param>
        /// <param name="guestemail">客人电子邮件</param>
        /// <param name="remark">备注</param>
        /// <param name="from">订单来源</param>
        /// <param name="status">订单状态</param>
        /// <param name="msg">错误信息</param>
        /// <returns></returns>
        public static bool modresv(int pid, string confnum, string firstname, string lastname, string guestaddressline1, string guestphone, string guestemail, string remark, string from, out string status, out string msg)
        {
            return modresv(new ResvModifyInfo { pid = pid, confnum = confnum, firstname = firstname, lastname = lastname, guestaddressline1 = guestaddressline1, guestphone = guestphone, guestemail = guestemail, remark = remark, from = from }, out status, out msg);
        }

        /// <summary>
        /// 酒店新预订
        /// </summary>
        /// <param name="resv">订单信息</param>
        /// <param name="confnum">确认号</param>
        /// <param name="status">订单状态</param>
        /// <param name="msg">out类型的错误信息</param>
        /// <returns></returns>
        public static bool newresv(ResvInfo resv, out string confnum, out string status, out string msg)
        {
            confnum = "";
            msg = "";
            status = "";
            string xml = FogXml.newresv("newresv", resv, out msg);
            XmlDocument document = new XmlDocument();
            if (xml.Length >= 1)
            {
                try
                {
                    document.LoadXml(xml);
                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
                    nsmgr.AddNamespace("err", "http://www.hubs1.net/gxml/error");
                    XmlNode node = document.SelectSingleNode("//err:srvmessage", nsmgr);
                    if (node == null)
                    {
                        node = document.SelectSingleNode("srvmessage");
                    }
                    if (node == null)
                    {
                        throw new Exception("文档解析出错:[" + xml + "]");
                    }
                    if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNode node2 = document.SelectSingleNode("//resvdetail");
                        if (node2.ChildNodes.Count > 0)
                        {
                            foreach (XmlElement element in node2)
                            {
                                if (element.Name == "confnum")
                                {
                                    confnum = element.InnerText;
                                }
                                else if (element.Name == "status")
                                {
                                    status = element.InnerText;
                                }
                            }
                            return true;
                        }
                        msg = "ErrConfnum";
                    }
                    else
                    {
                        XmlNodeList list = document.SelectNodes("//err:error", nsmgr);
                        foreach (XmlNode node3 in list)
                        {
                            foreach (XmlElement element in node3.ChildNodes)
                            {
                                if (element.Name == "errormsg")
                                {
                                    msg = msg + "|" + element.InnerText;
                                }
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    msg = "ErrXMLdoc";
                    WebError.SendErrorEmail(exception);
                }
            }
            return false;
        }

        /// <summary>
        /// 酒店新预订
        /// </summary>
        /// <param name="actiontype">订单参数</param>
        /// <param name="resv">订单信息</param>
        /// <param name="confnum">确认号</param>
        /// <param name="status">订单状态</param>
        /// <param name="msg">out类型的错误信息</param>
        /// <returns></returns>
        public static bool newresv(string actiontype, ResvInfo resv, out string confnum, out string status, out string msg)
        {
            confnum = "";
            msg = "";
            status = "";
            string xml = FogXml.newresv(actiontype, resv, out msg);
            XmlDocument document = new XmlDocument();
            if (xml.Length >= 1)
            {
                try
                {
                    document.LoadXml(xml);
                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
                    nsmgr.AddNamespace("err", "http://www.hubs1.net/gxml/error");
                    XmlNode node = document.SelectSingleNode("//err:srvmessage", nsmgr);
                    if (node == null)
                    {
                        node = document.SelectSingleNode("srvmessage");
                    }
                    if (node == null)
                    {
                        throw new Exception("文档解析出错:[" + xml + "]");
                    }
                    if (node.Attributes.GetNamedItem("result").InnerXml == "success")
                    {
                        XmlNode node2 = document.SelectSingleNode("//resvdetail");
                        if (node2.ChildNodes.Count > 0)
                        {
                            foreach (XmlElement element in node2)
                            {
                                if (element.Name == "confnum")
                                {
                                    confnum = element.InnerText;
                                }
                                else if (element.Name == "status")
                                {
                                    status = element.InnerText;
                                }
                            }
                            return true;
                        }
                        msg = "ErrConfnum";
                    }
                    else
                    {
                        XmlNodeList list = document.SelectNodes("//err:error", nsmgr);
                        foreach (XmlNode node3 in list)
                        {
                            foreach (XmlElement element in node3.ChildNodes)
                            {
                                if (element.Name == "errormsg")
                                {
                                    msg = msg + "|" + element.InnerText;
                                }
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    msg = "ErrXMLdoc";
                    WebError.SendErrorEmail(exception);
                }
            }
            return false;
        }

        /// <summary>
        /// 根据订单GUID发送传真(Fax_Confirmation_[mailtype].txt)
        /// </summary>
        /// <param name="Procedure">存储过程名称,参数为@verifycode.</param>
        /// <param name="url">网站url</param>
        /// <param name="folder">文件目录，可用HttpContext.Current.Request.PhysicalApplicationPath （mail）网站根目录下文件夹</param>
        /// <param name="verifycode">订单Guid</param>
        /// <param name="mailtype">邮件类型</param>
        /// <param name="title">邮件主题</param>
        /// <param name="lantype">语言类型(1:en,0,cn)</param>
        /// <param name="faxphone"></param>
        /// <param name="faxemail"></param>
        /// <returns></returns>
        public static string SendFax_GUID(string Procedure, string url, string folder, string verifycode, string mailtype, string title, int lantype, string faxphone, string faxemail)
        {
            string str = "";
            try
            {
                string html = "";
                string path = folder + @"\Fax_Confirmation_" + mailtype + ".txt";
                try
                {
                    StreamReader reader = File.OpenText(path);
                    html = reader.ReadToEnd();
                    reader.Close();
                    reader = null;
                }
                catch (Exception)
                {
                    html = "";
                    if (lantype == 1)
                    {
                        return "Can't find Fax template";
                    }
                    return "没有找到传真模板";
                }
                Functions functions = new Functions();
                DataSet set = CommonDataAccess.ExecProcedure(Procedure, "@verifycode", "string", new object[] { verifycode });
                DataTable table = new DataTable();
                string newValue = "";
                string str5 = "";
                if ((set != null) && (set.Tables.Count > 0))
                {
                    table = set.Tables[0];
                    DataTable table2 = set.Tables[1];
                    DataRow[] rowArray = table2.Select("fieldtype='Otherguests'");
                    if (rowArray.Length > 0)
                    {
                        newValue = rowArray[0]["fieldvalue"].ToString();
                    }
                    rowArray = table2.Select("fieldtype='SpecRequirement'");
                    if (rowArray.Length > 0)
                    {
                        str5 = rowArray[0]["fieldvalue"].ToString();
                    }
                    rowArray = Specialrequirement.Select("code in('" + str5.Replace(",", "','") + "')");
                    str5 = "";
                    if (lantype == 0)
                    {
                        foreach (DataRow row in rowArray)
                        {
                            str5 = str5 + row["zh"].ToString() + "、";
                        }
                    }
                    else
                    {
                        foreach (DataRow row in rowArray)
                        {
                            str5 = str5 + row["en"].ToString() + ",";
                        }
                    }
                    if (str5.Length > 0)
                    {
                        str5 = str5.Substring(0, str5.Length - 1);
                    }
                }
                html = html.Replace("<%=specialrequirements%>", str5).Replace("<%=otherguests%>", newValue);
                if ((table == null) || (table.Rows.Count < 1))
                {
                    if (lantype == 0)
                    {
                        return "对应记录未找到，确认传真不能发送";
                    }
                    return "Can't find this reservation record,please try again";
                }
                string source = table.Rows[0]["ccnumber"].ToString();
                if (source.Length > 1)
                {
                    source = CCEncrypt.Decrypto(source);
                    source = "************" + source.Substring(source.Length - 4, 4);
                }
                html.Replace("<%=enccnumber%>", source);
                string str7 = "";
                string str8 = "";
                if (table.Rows.Count != 0)
                {
                    int num;
                    if (lantype == 0)
                    {
                        str7 = table.Rows[0]["title"].ToString() + title;
                    }
                    else
                    {
                        str7 = table.Rows[0]["title_e"].ToString() + title;
                    }
                    str8 = table.Rows[0]["guestemail"].ToString();
                    string str9 = DateTime.Now.ToString();
                    string str10 = DateTime.Today.ToString("yyyy-MM-dd");
                    html = html.Replace("<%=url%>", url).Replace("<%=now%>", str9).Replace("<%=date%>", str10);
                    string resvInfoValue = ResvInfoUtil.GetResvInfoValue(table.Rows[0]["ResvInfo"].ToString(), ResvInfoType.holdTime);
                    html = html.Replace("<%=guestholdtime%>", resvInfoValue);
                    DataRow row = table.Rows[0];
                    string str12 = "";
                    for (num = 0; num < table.Columns.Count; num++)
                    {
                        str12 = table.Columns[num].ColumnName.ToLower().Trim();
                        html = html.Replace("<%=" + str12 + "%>", row[str12].ToString());
                    }
                    string[] strArray = table.Rows[0]["dailyprice"].ToString().Split(new char[] { '|' });
                    StringBuilder builder = new StringBuilder();
                    StringBuilder builder2 = new StringBuilder();
                    StringBuilder builder3 = new StringBuilder();
                    builder.Append("<table  width=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"TableList\" > ");
                    for (num = 0; num < (strArray.Length - 1); num += 7)
                    {
                        builder2.Remove(0, builder2.Length);
                        builder3.Remove(0, builder3.Length);
                        builder2.Append("<tr align=\"center\"> ");
                        builder3.Append("<tr align=\"center\">");
                        for (int i = 0; i < 7; i++)
                        {
                            if (((num + i) + 1) < strArray.Length)
                            {
                                builder2.Append("<th class=\"td3\">");
                                builder3.Append("<td  class=\"td4\">");
                                string[] strArray2 = strArray[(num + i) + 1].Split(new char[] { ',' });
                                builder2.Append(strArray2[0]);
                                builder3.Append(strArray2[1]);
                            }
                            else
                            {
                                builder2.Append("<th class=\"td3\">");
                                builder3.Append("<td  class=\"td4\">");
                            }
                            builder3.Append("</td>");
                            builder2.Append("</th>");
                        }
                        builder3.Append("</tr>");
                        builder2.Append("</tr>");
                        builder.Append(builder2);
                        builder.Append(builder3);
                    }
                    builder.Append("</table> ");
                    html = html.Replace("<%=pricelist%>", builder.ToString());
                    string[] mailTo = new string[] { faxemail };
                    try
                    {
                        if (lantype == 0)
                        {
                            functions.SendHTMLUTF8(html, faxphone, mailTo, faxemail, faxemail);
                        }
                        else
                        {
                            functions.SendHTMLUTF8(html, faxphone, mailTo, faxemail, faxemail);
                        }
                    }
                    catch
                    {
                        if (lantype == 0)
                        {
                            str = "<font color=red>确认传真发送有误</font>";
                        }
                        else
                        {
                            str = "<font color=red>Fax delivery failed!</font>";
                        }
                    }
                    return str;
                }
                if (lantype == 0)
                {
                    str = "对应记录未找到，确认传真不能发送";
                }
                else
                {
                    str = "Can't find this reservation record,please try again";
                }
            }
            catch (Exception)
            {
                if (lantype == 1)
                {
                    str = "Can't find Fax template";
                }
                else
                {
                    str = "没有找到传真模板";
                }
            }
            return str;
        }

        /// <summary>
        /// 根据订单GUID发送html邮件，模板文件名称为(Email_Confirmation_[mailtype].txt)
        /// </summary>
        /// <param name="Procedure">存储过程名称,参数为@verifycode.</param>
        /// <param name="url">网站url</param>
        /// <param name="folder">文件目录，可用HttpContext.Current.Request.PhysicalApplicationPath （mail）网站根目录下文件夹</param>
        /// <param name="verifycode">订单Guid</param>
        /// <param name="mailtype">邮件类型</param>
        /// <param name="title">邮件主题</param>
        /// <param name="lantype">语言类型(1:en,0,cn)</param>
        /// <param name="Webfrom">显示的发送人</param>
        /// <param name="Webmail">显示的发送邮箱</param>
        /// <returns></returns>
        public static string SendHTMLEmail_GUID(string Procedure, string url, string folder, string verifycode, string mailtype, string title, int lantype, string Webfrom, string Webmail)
        {
            string str = "";
            try
            {
                string html = "";
                string path = folder + @"\Email_Confirmation_" + mailtype + ".txt";
                try
                {
                    StreamReader reader = File.OpenText(path);
                    html = reader.ReadToEnd();
                    reader.Close();
                    reader = null;
                }
                catch (Exception)
                {
                    html = "";
                    if (lantype == 1)
                    {
                        return "Can't find Email template";
                    }
                    return "没有找到邮件模板";
                }
                Functions functions = new Functions();
                DataSet set = CommonDataAccess.ExecProcedure(Procedure, "@verifycode", "string", new object[] { verifycode });
                DataTable table = new DataTable();
                string newValue = "";
                string str5 = "";
                if ((set != null) && (set.Tables.Count > 0))
                {
                    table = set.Tables[0];
                    DataTable table2 = set.Tables[1];
                    DataRow[] rowArray = table2.Select("fieldtype='Otherguests'");
                    if (rowArray.Length > 0)
                    {
                        newValue = rowArray[0]["fieldvalue"].ToString();
                    }
                    rowArray = table2.Select("fieldtype='SpecRequirement'");
                    if (rowArray.Length > 0)
                    {
                        str5 = rowArray[0]["fieldvalue"].ToString();
                    }
                    rowArray = Specialrequirement.Select("code in('" + str5.Replace(",", "','") + "')");
                    str5 = "";
                    if (lantype == 0)
                    {
                        foreach (DataRow row in rowArray)
                        {
                            str5 = str5 + row["zh"].ToString() + "、";
                        }
                    }
                    else
                    {
                        foreach (DataRow row in rowArray)
                        {
                            str5 = str5 + row["en"].ToString() + ",";
                        }
                    }
                    if (str5.Length > 0)
                    {
                        str5 = str5.Substring(0, str5.Length - 1);
                    }
                }
                html = html.Replace("<%=specialrequirements%>", str5).Replace("<%=otherguests%>", newValue);
                if ((table == null) || (table.Rows.Count < 1))
                {
                    if (lantype == 0)
                    {
                        return "对应记录未找到，确认邮件不能发送";
                    }
                    return "Can't find this reservation record,please try again";
                }
                string source = table.Rows[0]["ccnumber"].ToString();
                if (source.Length > 1)
                {
                    source = CCEncrypt.Decrypto(source);
                    source = "************" + source.Substring(source.Length - 4, 4);
                }
                html = html.Replace("<%=enccnumber%>", source);
                string str7 = "";
                string str8 = "";
                if (table.Rows.Count != 0)
                {
                    int num;
                    if (lantype == 0)
                    {
                        str7 = table.Rows[0]["title"].ToString() + title;
                    }
                    else
                    {
                        str7 = table.Rows[0]["title_e"].ToString() + title;
                    }
                    str8 = table.Rows[0]["guestemail"].ToString();
                    string str9 = DateTime.Now.ToString();
                    string str10 = DateTime.Today.ToString("yyyy-MM-dd");
                    html = html.Replace("<%=url%>", url).Replace("<%=now%>", str9).Replace("<%=date%>", str10);
                    string resvInfoValue = ResvInfoUtil.GetResvInfoValue(table.Rows[0]["ResvInfo"].ToString(), ResvInfoType.holdTime);
                    html = html.Replace("<%=guestholdtime%>", resvInfoValue);
                    DataRow row = table.Rows[0];
                    string str12 = "";
                    for (num = 0; num < table.Columns.Count; num++)
                    {
                        str12 = table.Columns[num].ColumnName.ToLower().Trim();
                        html = html.Replace("<%=" + str12 + "%>", row[str12].ToString());
                    }
                    string[] strArray = table.Rows[0]["dailyprice"].ToString().Split(new char[] { '|' });
                    StringBuilder builder = new StringBuilder();
                    StringBuilder builder2 = new StringBuilder();
                    StringBuilder builder3 = new StringBuilder();
                    string str13 = table.Rows[0]["breakfast"].ToString();
                    string[] strArray2 = str13.Split(new char[] { ',' });
                    builder.Append("<table  width=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"TableList\" > ");
                    for (num = 0; num < (strArray.Length - 1); num += 7)
                    {
                        builder2.Remove(0, builder2.Length);
                        builder3.Remove(0, builder3.Length);
                        builder2.Append("<tr align=\"center\"> ");
                        builder3.Append("<tr align=\"center\">");
                        for (int i = 0; i < 7; i++)
                        {
                            if (((num + i) + 1) < strArray.Length)
                            {
                                builder2.Append("<th class=\"td3\">");
                                builder3.Append("<td  class=\"td4\">");
                                string[] strArray3 = strArray[(num + i) + 1].Split(new char[] { ',' });
                                builder2.Append(strArray3[0]);
                                builder3.Append(strArray3[1]);
                                try
                                {
                                    if (str13.Trim().Length > 0)
                                    {
                                        builder3.Append("<br/>" + GetBreakfastRemark(strArray2[num + i], lantype));
                                    }
                                }
                                catch
                                {
                                }
                            }
                            else
                            {
                                builder2.Append("<th class=\"td3\">");
                                builder3.Append("<td  class=\"td4\">");
                            }
                            builder3.Append("</td>");
                            builder2.Append("</th>");
                        }
                        builder3.Append("</tr>");
                        builder2.Append("</tr>");
                        builder.Append(builder2);
                        builder.Append(builder3);
                    }
                    builder.Append("</table> ");
                    html = html.Replace("<%=pricelist%>", builder.ToString());
                    string[] mailTo = null;
                    string[] strArray5 = Webmail.Split(new char[] { ',' });
                    int num3 = strArray5.Length - 1;
                    mailTo = new string[2 + num3];
                    if (mailtype == "CC")
                    {
                        mailTo[0] = "service@hubs1.net";
                    }
                    else
                    {
                        mailTo[0] = "isaac.wang@hubs1.net";
                    }
                    mailTo[1] = str8;
                    for (num = 1; num < strArray5.Length; num++)
                    {
                        mailTo[num + 1] = strArray5[num];
                    }
                    try
                    {
                        if (lantype == 0)
                        {
                            functions.SendHTMLUTF8(html, str7, mailTo, strArray5[0], Webfrom);
                        }
                        else
                        {
                            functions.SendHTMLUTF8(html, str7, mailTo, strArray5[0], Webfrom);
                        }
                    }
                    catch
                    {
                        if (lantype == 0)
                        {
                            str = "<font color=red>确认邮件发送有误</font>";
                        }
                        else
                        {
                            str = "<font color=red>E-mail delivery failed!</font>";
                        }
                    }
                    return str;
                }
                if (lantype == 0)
                {
                    str = "对应记录未找到，确认邮件不能发送";
                }
                else
                {
                    str = "Can't find this reservation record,please try again";
                }
            }
            catch (Exception)
            {
                if (lantype == 1)
                {
                    str = "Can't find Email template";
                }
                else
                {
                    str = "没有找到邮件模板";
                }
            }
            return str;
        }

        /// <summary>
        /// 根据订单GUID发送html邮件，模板文件名称为(Email_Confirmation_[mailtype].txt)
        /// </summary>
        /// <param name="Procedure">存储过程名称,参数为@verifycode.</param>
        /// <param name="url">网站url</param>
        /// <param name="folder">文件目录，可用HttpContext.Current.Request.PhysicalApplicationPath （mail）网站根目录下文件夹</param>
        /// <param name="verifycode">订单Guid</param>
        /// <param name="mailtype">邮件类型</param>
        /// <param name="title">邮件主题</param>
        /// <param name="lantype">语言类型(1:en,0,cn)</param>
        /// <param name="Webfrom">显示的发送人</param>
        /// <param name="Webmail">显示的发送邮箱</param>
        /// <param name="IsSendFrom">是否发送发送邮箱</param>
        /// <returns></returns>
        public static string SendHTMLEmail_GUID(string Procedure, string url, string folder, string verifycode, string mailtype, string title, int lantype, string Webfrom, string Webmail, bool IsSendFrom)
        {
            string str = "";
            try
            {
                string html = "";
                string path = folder + @"\Email_Confirmation_" + mailtype + ".txt";
                try
                {
                    StreamReader reader = File.OpenText(path);
                    html = reader.ReadToEnd();
                    reader.Close();
                    reader = null;
                }
                catch (Exception)
                {
                    html = "";
                    if (lantype == 1)
                    {
                        return "Can't find Email template";
                    }
                    return "没有找到邮件模板";
                }
                Functions functions = new Functions();
                DataSet set = CommonDataAccess.ExecProcedure(Procedure, "@verifycode", "string", new object[] { verifycode });
                DataTable table = new DataTable();
                string newValue = "";
                string str5 = "";
                if ((set != null) && (set.Tables.Count > 0))
                {
                    table = set.Tables[0];
                    DataTable table2 = set.Tables[1];
                    DataRow[] rowArray = table2.Select("fieldtype='Otherguests'");
                    if (rowArray.Length > 0)
                    {
                        newValue = rowArray[0]["fieldvalue"].ToString();
                    }
                    rowArray = table2.Select("fieldtype='SpecRequirement'");
                    if (rowArray.Length > 0)
                    {
                        str5 = rowArray[0]["fieldvalue"].ToString();
                    }
                    rowArray = Specialrequirement.Select("code in('" + str5.Replace(",", "','") + "')");
                    str5 = "";
                    if (lantype == 0)
                    {
                        foreach (DataRow row in rowArray)
                        {
                            str5 = str5 + row["zh"].ToString() + "、";
                        }
                    }
                    else
                    {
                        foreach (DataRow row in rowArray)
                        {
                            str5 = str5 + row["en"].ToString() + ",";
                        }
                    }
                    if (str5.Length > 0)
                    {
                        str5 = str5.Substring(0, str5.Length - 1);
                    }
                }
                html = html.Replace("<%=specialrequirements%>", str5).Replace("<%=otherguests%>", newValue);
                if ((table == null) || (table.Rows.Count < 1))
                {
                    if (lantype == 0)
                    {
                        return "对应记录未找到，确认邮件不能发送";
                    }
                    return "Can't find this reservation record,please try again";
                }
                string source = table.Rows[0]["ccnumber"].ToString();
                if (source.Length > 1)
                {
                    source = CCEncrypt.Decrypto(source);
                    source = "************" + source.Substring(source.Length - 4, 4);
                }
                html = html.Replace("<%=enccnumber%>", source);
                string str7 = "";
                string str8 = "";
                if (table.Rows.Count != 0)
                {
                    int num;
                    if (lantype == 0)
                    {
                        str7 = table.Rows[0]["title"].ToString() + title;
                    }
                    else
                    {
                        str7 = table.Rows[0]["title_e"].ToString() + title;
                    }
                    str8 = table.Rows[0]["guestemail"].ToString();
                    string str9 = DateTime.Now.ToString();
                    string str10 = DateTime.Today.ToString("yyyy-MM-dd");
                    html = html.Replace("<%=url%>", url).Replace("<%=now%>", str9).Replace("<%=date%>", str10);
                    string resvInfoValue = ResvInfoUtil.GetResvInfoValue(table.Rows[0]["ResvInfo"].ToString(), ResvInfoType.holdTime);
                    html = html.Replace("<%=guestholdtime%>", resvInfoValue);
                    DataRow row = table.Rows[0];
                    string str12 = "";
                    for (num = 0; num < table.Columns.Count; num++)
                    {
                        str12 = table.Columns[num].ColumnName.ToLower().Trim();
                        html = html.Replace("<%=" + str12 + "%>", row[str12].ToString());
                    }
                    string[] strArray = table.Rows[0]["dailyprice"].ToString().Split(new char[] { '|' });
                    StringBuilder builder = new StringBuilder();
                    StringBuilder builder2 = new StringBuilder();
                    StringBuilder builder3 = new StringBuilder();
                    string str13 = table.Rows[0]["breakfast"].ToString();
                    string[] strArray2 = str13.Split(new char[] { ',' });
                    builder.Append("<table  width=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"TableList\" > ");
                    for (num = 0; num < (strArray.Length - 1); num += 7)
                    {
                        builder2.Remove(0, builder2.Length);
                        builder3.Remove(0, builder3.Length);
                        builder2.Append("<tr align=\"center\"> ");
                        builder3.Append("<tr align=\"center\">");
                        for (int i = 0; i < 7; i++)
                        {
                            if (((num + i) + 1) < strArray.Length)
                            {
                                builder2.Append("<th class=\"td3\">");
                                builder3.Append("<td  class=\"td4\">");
                                string[] strArray3 = strArray[(num + i) + 1].Split(new char[] { ',' });
                                builder2.Append(strArray3[0]);
                                builder3.Append(strArray3[1]);
                                try
                                {
                                    if (str13.Trim().Length > 0)
                                    {
                                        builder3.Append("<br/>" + GetBreakfastRemark(strArray2[num + i], lantype));
                                    }
                                }
                                catch
                                {
                                }
                            }
                            else
                            {
                                builder2.Append("<th class=\"td3\">");
                                builder3.Append("<td  class=\"td4\">");
                            }
                            builder3.Append("</td>");
                            builder2.Append("</th>");
                        }
                        builder3.Append("</tr>");
                        builder2.Append("</tr>");
                        builder.Append(builder2);
                        builder.Append(builder3);
                    }
                    builder.Append("</table> ");
                    html = html.Replace("<%=pricelist%>", builder.ToString());
                    string[] mailTo = null;
                    string[] strArray5 = Webmail.Split(new char[] { ',' });
                    int num3 = 0;
                    if (IsSendFrom)
                    {
                        num3 = strArray5.Length - 1;
                    }
                    mailTo = new string[2 + num3];
                    if (mailtype == "CC")
                    {
                        mailTo[0] = "service@hubs1.net";
                    }
                    else
                    {
                        mailTo[0] = "isaac.wang@hubs1.net";
                    }
                    mailTo[1] = str8;
                    if (IsSendFrom)
                    {
                        for (num = 1; num < strArray5.Length; num++)
                        {
                            mailTo[num + 1] = strArray5[num];
                        }
                    }
                    try
                    {
                        if (lantype == 0)
                        {
                            functions.SendHTMLUTF8(html, str7, mailTo, strArray5[0], Webfrom);
                        }
                        else
                        {
                            functions.SendHTMLUTF8(html, str7, mailTo, strArray5[0], Webfrom);
                        }
                    }
                    catch
                    {
                        if (lantype == 0)
                        {
                            str = "<font color=red>确认邮件发送有误</font>";
                        }
                        else
                        {
                            str = "<font color=red>E-mail delivery failed!</font>";
                        }
                    }
                    return str;
                }
                if (lantype == 0)
                {
                    str = "对应记录未找到，确认邮件不能发送";
                }
                else
                {
                    str = "Can't find this reservation record,please try again";
                }
            }
            catch (Exception)
            {
                if (lantype == 1)
                {
                    str = "Can't find Email template";
                }
                else
                {
                    str = "没有找到邮件模板";
                }
            }
            return str;
        }

        /// <summary>
        /// 更新酒店价格支持多人价格（2009-03-17 by field ）
        /// </summary>
        /// <param name="person">入住人数</param>
        /// <param name="language">语言</param>
        /// <param name="Property_id">酒店pid</param>
        /// <param name="plancode">计划代码</param>
        /// <param name="Availdate">入住日期</param>
        /// <param name="singlerate">单人价</param>
        /// <param name="doublerate">双人价</param>
        /// <param name="triplerate">三人价</param>
        /// <param name="quadrate">四人价</param>
        /// <param name="extraadult">成人加床价</param>
        /// <param name="extrachildren">儿童加床价</param>
        /// <param name="Allotment">No. of Room(s)量</param>
        /// <param name="AllotMax"></param>
        /// <param name="AvStat"></param>
        /// <param name="MaxLos"></param>
        /// <param name="MinLos"></param>
        /// <param name="RateCode"></param>
        /// <param name="RoomCode"></param>
        /// <param name="Tcode"></param>
        /// <param name="T_from"></param>
        /// <param name="T_to"></param>
        /// <param name="Roomdesc"></param>
        /// <param name="plandesc"></param>
        /// <param name="Gua"></param>
        /// <param name="Cxl"></param>
        /// <param name="PriceNoTax"></param>
        /// <param name="cutOff"></param>
        /// <param name="planname"></param>
        /// <param name="roomname"></param>
        private static bool UpdateH_Cache(int person, int language, int Property_id, string plancode, string Availdate, decimal singlerate, decimal doublerate, decimal triplerate, decimal quadrate, decimal extraadult, decimal extrachildren, int Allotment, int AllotMax, string AvStat, int MaxLos, int MinLos, string RateCode, string RoomCode, string Tcode, string T_from, string T_to, string Roomdesc, string plandesc, string Gua, string Cxl, decimal PriceNoTax, int cutOff, string planname, string roomname)
        {
            string msg = "";
            DataTable table = CommonDataAccess.GetTable(string.Concat(new object[] { "select top 1 * from h_cache with(nolock) where property_id=", Property_id, " and plancode='", plancode, "' and availdate='", Availdate, "'" }), "rate");
            if ((table != null) && (table.Rows.Count > 0))
            {
                CommonDataAccess.ExecUpdateSQL("h_cache", new string[] { 
                    "singlerate", "doublerate", "triplerate", "quadrate", "extraadult", "extrachildren", "Allotment", "AllotMax", "AvStat", "MaxLos", "MinLos", "RateCode", "RoomCode", "Tcode", "T_from", "T_to", 
                    "Gua", "Cxl", "PriceNoTax", "cutOff"
                 }, new string[] { 
                    "decimal", "decimal", "decimal", "decimal", "decimal", "decimal", "int", "int", "string", "int", "int", "string", "string", "string", "datetime", "datetime", 
                    "string", "string", "decimal", "int"
                 }, new object[] { 
                    singlerate, doublerate, triplerate, quadrate, extraadult, extrachildren, Allotment, AllotMax, AvStat, MaxLos, MinLos, RateCode, RoomCode, Tcode, T_from, T_to, 
                    Gua, Cxl, PriceNoTax, cutOff
                 }, new string[] { "Property_id", "plancode", "Availdate" }, new string[] { "int", "string", "datetime" }, new object[] { Property_id, plancode, Availdate }, out msg);
            }
            else
            {
                CommonDataAccess.ExecInsertSQL("h_cache", new string[] { 
                    "Property_id", "plancode", "Availdate", "singlerate", "doublerate", "triplerate", "quadrate", "extraadult", "extrachildren", "Allotment", "AllotMax", "AvStat", "MaxLos", "MinLos", "RateCode", "RoomCode", 
                    "Tcode", "T_from", "T_to", "Gua", "Cxl", "PriceNoTax", "cutOff"
                 }, new string[] { 
                    "int", "string", "datetime", "decimal", "decimal", "decimal", "decimal", "decimal", "decimal", "int", "int", "string", "int", "int", "string", "string", 
                    "string", "datetime", "datetime", "string", "string", "decimal", "int"
                 }, new object[] { 
                    Property_id, plancode, Availdate, singlerate, doublerate, triplerate, quadrate, extraadult, extrachildren, Allotment, AllotMax, AvStat, MaxLos, MinLos, RateCode, RoomCode, 
                    Tcode, T_from, T_to, Gua, Cxl, PriceNoTax, cutOff
                 }, out msg);
            }
            if (CommonDataAccess.IsExist(string.Concat(new object[] { "select top 1 property_id from h_plan with(nolock) where property_id=", Property_id, " and plancode='", plancode, "' and languagetype=", language, " " })))
            {
                CommonDataAccess.ExecUpdateSQL("h_plan", new string[] { "roomCode", "planname", "roomname", "roomdesc", "plandesc", "type" }, new string[] { "string", "string", "string", "string", "string", "string" }, new object[] { RoomCode, planname, roomname, Roomdesc, plandesc, "plan" }, new string[] { "Property_id", "plancode", "languagetype" }, new string[] { "int", "string", "int" }, new object[] { Property_id, plancode, language }, out msg);
            }
            else
            {
                CommonDataAccess.ExecInsertSQL("h_plan", new string[] { "Property_id", "plancode", "languagetype", "roomCode", "planname", "roomname", "roomdesc", "plandesc", "type" }, new string[] { "int", "string", "int", "string", "string", "string", "string", "string", "string" }, new object[] { Property_id, plancode, language, RoomCode, planname, roomname, Roomdesc, plandesc, "plan" }, out msg);
            }
            return true;
        }

        /// <summary>
        /// 客人取消订单原因 (其他：CRG99)code,zh,en
        /// </summary>
        public static DataTable Cxlreason
        {
            get
            {
                return _Cxlreason;
            }
        }

        /// <summary>
        /// 客人特殊需求 code,zh,en
        /// </summary>
        public static DataTable Specialrequirement
        {
            get
            {
                return _Specialrequirement;
            }
        }
    }
}

